<template>
  <div class="home">
    <div class="header">
      <div class="logo"></div>
      <div class="titleMain">
        <h1>系统运维监控</h1>
      </div>
    </div>
    <div class="container">
      <div class="process" v-if="processInfo.length > 0">
        <div class="title">
          <div><span class="white title-main">进程监控</span></div>
          <div><span class="label title-sub">PROCESS MONITORING</span></div>
        </div>
        <div class="itemGroup">
          <div class="item" v-for="(item, index) in processInfo">
            <el-card>
              <template #header>
                <div class="card-header">
                  <div class="item-name">
                    <span class="white">{{ item.name }}</span>
                  </div>
                  <div class="lang" :style="{ backgroundColor: item.language === 'C++' ? '#0bc0db' : '#FF994A' }">
                    <span class="white">{{ item.language }}</span>
                  </div>
                </div>
              </template>
              <div>
                <div class="info-body">
                  <div class="img">
                    <img src="/src/assets/images/systemOperationMonitoring/process-icon.png" />
                  </div>
                  <div class="info">
                    <div class="info-item">
                      <span class="label title-sub label-sub">进程名</span>
                      <span class="white value">{{ item.name }}</span>
                    </div>
                    <div class="info-item">
                      <span class="label title-sub label-sub">计数器变量名</span>
                      <span class="white value">{{ item.counter }}</span>
                    </div>
                    <div class="info-item">
                      <span class="label title-sub label-sub">所在服务器</span>
                      <span class="white value">{{ item.server }}</span>
                    </div>
                    <div class="info-item">
                      <span class="label title-sub label-sub">发送给L1的中间件标志位变量名</span>
                      <span class="white value">{{ item.middleware }}</span>
                    </div>
                  </div>
                </div>
              </div>
              <div class="status-mark">
                <div class="status">
                  <div class="circle" :style="{ backgroundColor: item.status == '正常' ? '#63e775' : '#F55B5B' }"></div>
                  <div>
                    <span class="white">{{ item.status }}</span>
                  </div>
                </div>
                <div class="status">
                  <div class="label title-sub">异常需要切换</div>
                  <div>
                    <span class="white">{{ item.switch }}</span>
                  </div>
                </div>
                <div class="status">
                  <div class="label title-sub">异常报警不需要切换</div>
                  <div>
                    <span class="white">{{ item.alarm }}</span>
                  </div>
                </div>
              </div>
            </el-card>
          </div>
        </div>
      </div>
      <div class="communication">
        <div class="title">
          <div><span class="white title-main">通讯监控</span></div>
          <div><span class="label title-sub">COMMUNICATION MONITORING</span></div>
        </div>
        <div class="itemGroup">
          <div class="item"></div>
          <div class="item"></div>
          <div class="item"></div>
          <div class="item"></div>
        </div>
      </div>
    </div>
  </div>
</template>
<script lang="ts" setup>
  import { ref, onMounted } from 'vue';

  const processInfo = ref<any>([
    {
      name: 'CAL1630_spm',
      language: 'C++',
      counter: 'counter 100ms',
      server: '1630模型服务器',
      middleware: 'CAL1 ROLL.Fspare12',
      status: '正常',
      switch: '01',
      alarm: '02',
    },
    {
      name: 'Model show',
      language: 'JAVA',
      counter: 'counter 100ms',
      server: '1630模型服务器',
      middleware: 'CAL1 DIR.Sspare10',
      status: '异常',
      switch: '01',
      alarm: '02',
    },
    {
      name: 'TCM EFF TRACK',
      language: 'C++',
      counter: 'tcm eff track check',
      server: '1630模型服务器',
      middleware: 'PLTCM DATA.Fspare58',
      status: '正常',
      switch: '01',
      alarm: '02',
    },
    {
      name: 'PAOPIAN',
      language: 'C++',
      counter: 'pp_counter 100ms',
      server: '2280模型服务器',
      middleware: 'CAL1 SPMDIR.Fspare43',
      status: '正常',
      switch: '01',
      alarm: '02',
    },
  ]);
</script>
<style lang="less" scoped>
  .home {
    background-size: cover;
    position: relative;
    overflow: hidden;
    height: 100vh;
    background-size: 100% 100%;
  }
  .container {
    min-height: 100vh;
    margin-top: -3vh;
    margin-right: 1vw;
    display: flex;
    flex-direction: column;
    gap: 2vh;

    .white {
      color: #fff;
    }
    .label {
      color: #ccc;
    }

    :deep(.el-card) {
      border: none !important;
    }

    :deep(.el-card__header) {
      height: 2vh;
      display: flex;
      align-items: center;
      border-bottom: none;
      background-color: #122d6c;
      background-image: url(/src/assets/images/systemOperationMonitoring/card-header.png);
      background-size: cover;
      padding: 2vh 0;
    }

    :deep(.el-card__body) {
      background-color: #122d6c;
    }
  }

  .process,
  .communication {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2vh;
    margin: 0.5%;
    padding: 0.5%;
  }

  .title {
    width: 100%;
    display: flex;
    align-items: center;
    min-height: 4vh;
    padding: 0 0 0 0.5%;
    gap: 10px;
    background-image: url(/src/assets/images/systemOperationMonitoring/title-bg.png);
    background-size: 100% auto;
  }

  .title-main {
    font-size: 1.4rem;
    font-weight: 700;
  }

  .title-sub {
    font-weight: 400;
  }

  .itemGroup {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
  }

  .card-header {
    width: calc(100% - 2rem);
    display: flex;
    // flex: 1;
    align-items: center;
    justify-content: space-between;
    margin-left: 2rem;
    margin-right: 0;
  }

  .lang {
    padding: 5px;
    // background-color: #0bc0db;
    display: flex;
    margin-right: 0;
    align-items: center;
    font-size: 1.2rem;
    font-weight: bold;
  }

  .item-name {
    display: flex;
    align-items: center;
    font-size: 1.2rem;
  }

  .info-body {
    display: flex;
    flex-wrap: nowrap;

    .info {
      flex-grow: 1;
      display: flex;
      flex-direction: column;
      gap: 14px;
      margin-left: 1vw;

      .info-item {
        width: 100%;
        display: flex;
        flex-wrap: wrap; /* 标签和内容可换行 */
        gap: 0.5rem;

        .label-sub {
          min-width: 6vw;
          text-align: left;
        }
        .value {
          flex: 1;
          text-align: left;
        }
      }
    }
  }

  .status-mark {
    display: flex;
    flex-wrap: nowrap;
    gap: 2rem;
    align-items: center;
    font-size: 1.1rem;

    .status {
      display: flex;
      flex-wrap: nowrap;
      align-items: center;
      gap: 1rem;
    }
  }

  .circle {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #e5f1fe;
    border-radius: 4px;
    width: 1.7rem;
    height: 0.7rem;
    min-width: 1.7rem;
    min-height: 0.7rem;
    flex-shrink: 0;
    // color: #63e775;
    // background-color: #63e775;
    font-weight: 600;
    font-size: 0.8rem;
  }
</style>
